#include "insn.h"
#include <stdio.h>


void kyber1024_keygen(void){
//opcode, func3, func7, rd, rs1, rs2
		//SHA3_Enable,6'b000001
		//rs1=d rs2=0 dst=1    	//G（Seed）000
		asm volatile (".insn r 0x0b, 0, 0b0000001, x1, x0, x0");

		//SHA3_Enable,6'B010000
		//rs1=σ rs2=0 dst=0  	//采样s0 000
		asm volatile (".insn r 0x0b, 0, 0b0010000, x0, x2, x0");
		//Poly_Enable,`NTT
		//rs1=0 rs2=0 dst=0    //NTT s0 001 RAM3+RAM1第一轮 to RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000000, x16, x0, x0");
		//SHA3_Enable,6'B010001
		//rs1=σ rs2=0 dst=1	//采样s1 000
		asm volatile (".insn r 0x0b, 0, 0b0010001, x1, x2, x0");
		//Poly_Enable,`NTT
		//rs1=0 rs2=1 dst=1   //NTT s1 001 RAM3+RAM1第一轮 to RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000000, x17, x0, x1");
		//SHA3_Enable,6'B010010
		//rs1=σ rs2=0 dst=2	//采样s2 000
		asm volatile (".insn r 0x0b, 0, 0b0010010, x2, x2, x0");
		//Poly_Enable,`NTT
		//rs1=0 rs2=2 dst=2   //NTT s2 001 RAM3+RAM1第一轮 to RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000000, x18, x0, x2");
		//SHA3_Enable,6'B010011
		//rs1=σ rs2=0 dst=3	//采样s3 000
		asm volatile (".insn r 0x0b, 0, 0b0010011, x3, x2, x0");
		//Poly_Enable,`NTT
		//rs1=0 rs2=3 dst=3   //NTT s3 001 RAM3+RAM1第一轮 to RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000000, x19, x0, x3");


		//SHA3_Enable,6'B100000
		//rs1=ρ rs2=0 dst=0		//采样 AT 00  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100000, x0, x1, x0");

	///////////////////////////////PWM As0/////////////////////////
		//Poly_Enable,`PWM1
		//rs1=0 rs2=0 dst=0		//A00 s0 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x16, x0");
		//SHA3_Enable,6'B100001
		//rs1=ρ rs2=0 dst=1		//采样 AT 01  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100001, x1, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=0 rs2=1 dst=4		//A00 s0  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x0, x1");

		//Poly_Enable,`PWM1
		//rs1=1 rs2=1 dst=0		//A01 s1 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x17, x1");
		//SHA3_Enable,6'B100010
		//rs1=ρ rs2=0 dst=2		//采样 AT 02  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100010, x2, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=0 rs2=1 dst=5		//A01 s1  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x0, x1");

		//Poly_Enable,`PWM1
		//rs1=2 rs2=2 dst=0		//A02 s2 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x18, x2");
		//SHA3_Enable,6'B100011
		//rs1=ρ rs2=0 dst=3		//采样 AT 03  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100011, x3, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=0 rs2=1 dst=6		//A02 s2  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x0, x1");

		//Poly_Enable,`PWM1
		//rs1=3 rs2=3 dst=0		//A03 s3 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x19, x3");
		//SHA3_Enable,6'B100100
		//rs1=ρ rs2=0 dst=0		//采样 AT 10  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100100, x0, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=0 rs2=1 dst=7		//A03 s3  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x0, x1");

		//Poly_Enable,`PolyAdd
		//rs1=4 rs2=5 dst=0		//A01s1+A00s0  110  RAM2+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x20, x21");
		//Poly_Enable,`PolyAdd
		//rs1=0 rs2=6 dst=1		//ADD0+A02s2  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x0, x22");
		//Poly_Enable,`PolyAdd
		//rs1=1 rs2=7 dst=0		//ADD1+A03s3  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x1, x23");
	///////////////////////////////PWM As1/////////////////////////
		//Poly_Enable,`PWM1
		//rs1=0 rs2=0 dst=1		//A10 s0 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x16, x0");
		//SHA3_Enable,6'B100101
		//rs1=ρ rs2=0 dst=1		//采样 AT 11  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100101, x1, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=1 rs2=2 dst=4		//A00 s0  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x1, x2");

		//Poly_Enable,`PWM1
		//rs1=1 rs2=1 dst=1		//A11 s1 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x17, x1");
		//SHA3_Enable,6'B100110
		//rs1=ρ rs2=0 dst=2		//采样 AT 12  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100110, x2, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=1 rs2=2 dst=5		//A11 s1  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x1, x2");

		//Poly_Enable,`PWM1
		//rs1=2 rs2=2 dst=1		//A12 s2 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x18, x2");
		//SHA3_Enable,6'B100111
		//rs1=ρ rs2=0 dst=3		//采样 AT 13  ρ
		asm volatile (".insn r 0x0b, 0, 0b0100111, x3, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=1 rs2=2 dst=6		//A12 s2  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x1, x2");

		//Poly_Enable,`PWM1
		//rs1=3 rs2=3 dst=1		//A13 s3 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x19, x3");
		//SHA3_Enable,6'B101000
		//rs1=ρ rs2=0 dst=0		//采样 AT 20  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101000, x0, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=1 rs2=2 dst=7		//A13 s3  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x1, x2");

		//Poly_Enable,`PolyAdd
		//rs1=4 rs2=5 dst=1		//A11s1+A10s1  110  RAM2+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x20, x21");
		//Poly_Enable,`PolyAdd
		//rs1=1 rs2=6 dst=2		//ADD0+A12s2  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x1, x22");
		//Poly_Enable,`PolyAdd
		//rs1=2 rs2=7 dst=1		//ADD1+A13s3  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x2, x23");
	///////////////////////////////PWM As2/////////////////////////
		//Poly_Enable,`PWM1
		//rs1=0 rs2=0 dst=2		//A20 s0 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x16, x0");
		//SHA3_Enable,6'B101001
		//rs1=ρ rs2=0 dst=1		//采样 AT 21  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101001, x1, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=2 rs2=3 dst=4		//A20 s0  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x2, x3");

		//Poly_Enable,`PWM1
		//rs1=1 rs2=1 dst=2		//A21 s1 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x17, x1");
		//SHA3_Enable,6'B101010
		//rs1=ρ rs2=0 dst=2		//采样 AT 22  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101010, x2, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=2 rs2=3 dst=5		//A21 s1  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x2, x3");

		//Poly_Enable,`PWM1
		//rs1=2 rs2=2 dst=2		//A22 s2 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x18, x2");
		//SHA3_Enable,6'B101011
		//rs1=ρ rs2=0 dst=3		//采样 AT 23  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101011, x3, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=2 rs2=3 dst=6		//A22 s2  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x2, x3");

		//Poly_Enable,`PWM1
		//rs1=3 rs2=3 dst=2		//A23 s3 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x19, x3");
		//SHA3_Enable,6'B101100
		//rs1=ρ rs2=0 dst=0		//采样 AT 30  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101100, x0, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=2 rs2=3 dst=7		//A23 s3  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x2, x3");

		//Poly_Enable,`PolyAdd
		//rs1=4 rs2=5 dst=2		//A21s1+A20s0  110  RAM2+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x20, x21");
		//Poly_Enable,`PolyAdd
		//rs1=2 rs2=6 dst=3		//ADD0+A22s2  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x2, x22");
		//Poly_Enable,`PolyAdd
		//rs1=3 rs2=7 dst=2		//ADD1+A23s3  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x3, x23");
	///////////////////////////////PWM As3/////////////////////////
		//Poly_Enable,`PWM1
		//rs1=0 rs2=0 dst=3		//A30 s0 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x16, x0");
		//SHA3_Enable,6'B101101
		//rs1=ρ rs2=0 dst=1		//采样 AT 31  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101101, x1, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=3 rs2=4 dst=4		//A30 s0  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x3, x4");

		//Poly_Enable,`PWM1
		//rs1=1 rs2=1 dst=3		//A31 s1 PWM1 100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x17, x1");
		//SHA3_Enable,6'B101110
		//rs1=ρ rs2=0 dst=2		//采样 AT 32  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101110, x2, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=3 rs2=4 dst=5		//A21 s1  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x3, x4");

		//Poly_Enable,`PWM1
		//rs1=2 rs2=2 dst=3		//A32 s2 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x18, x2");
		//SHA3_Enable,6'B101111
		//rs1=ρ rs2=0 dst=3		//采样 AT 33  ρ
		asm volatile (".insn r 0x0b, 0, 0b0101111, x3, x1, x0");
		//Poly_Enable,`PWM2
		//rs1=3 rs2=4 dst=6		//A32 s2  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x3, x4");

		//Poly_Enable,`PWM1
		//rs1=3 rs2=3 dst=3		//A33 s3 PWM1    100
		asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x19, x3");
		//SHA3_Enable,6'B010100
		//rs1=σ rs2=0 dst=0		//采样 e0  σ
		asm volatile (".insn r 0x0b, 0, 0b0010100, x0, x2, x0");
		//Poly_Enable,`PWM2
		//rs1=3 rs2=4 dst=7		//A33 s3  PWM2   001
		asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x3, x4");

		//Poly_Enable,`PolyAdd
		//rs1=4 rs2=5 dst=3		//A31s1+A30s0  110  RAM2+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x20, x21");
		//Poly_Enable,`PolyAdd
		//rs1=3 rs2=6 dst=4		//ADD0+A32s2  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x3, x22");
		//Poly_Enable,`PolyAdd
		//rs1=4 rs2=7 dst=3		//ADD1+A33s3  010  RAM3+RAM2=RAM3
		asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x4, x23");

	///////////////////////////////e NTT/////////////////////////
		//Poly_Enable,`NTT
		//rs1=4 rs2=0 dst=4		//NTT e0   100
		asm volatile (".insn r 0x2b, 0, 0b0000000, x4, x20, x0");
		//SHA3_Enable,6'B010101
		//rs1=σ rs2=0 dst=1		//采样e1
		asm volatile (".insn r 0x0b, 0, 0b0010101, x1, x2, x0");
		//Poly_Enable,`PolyAdd
		//rs1=0 rs2=4 dst=4		//As0+e0  001  RAM3+RAM3=RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000100, x20, x0, x4");


		//Poly_Enable,`NTT
		//rs1=5 rs2=1 dst=4		//NTT e1   100
		asm volatile (".insn r 0x2b, 0, 0b0000000, x4, x21, x1");
		//SHA3_Enable,6'B010110
		//rs1=σ rs2=0 dst=2		//采样e2
		asm volatile (".insn r 0x0b, 0, 0b0010110, x2, x2, x0");
		//Poly_Enable,`PolyAdd
		//rs1=1 rs2=4 dst=5		//As1+e1  001  RAM3+RAM3=RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000100, x21, x1, x4");

		//Poly_Enable,`NTT
		//rs1=6 rs2=2 dst=4		//NTT e2   100
		asm volatile (".insn r 0x2b, 0, 0b0000000, x4, x22, x2");
		//SHA3_Enable,6'B010111
		//rs1=σ rs2=0 dst=3		//采样e3
		asm volatile (".insn r 0x0b, 0, 0b0010111, x3, x2, x0");
		//Poly_Enable,`PolyAdd
		//rs1=2 rs2=4 dst=6		//As2+e2  001  RAM3+RAM3=RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000100, x22, x2, x4");

		//Poly_Enable,`NTT
		//rs1=7 rs2=3 dst=4		//NTT e3   100
		asm volatile (".insn r 0x2b, 0, 0b0000000, x4, x23, x3");
		//Poly_Enable,`PolyAdd
		//rs1=3 rs2=4 dst=7		//As3+e3  001  RAM3+RAM3=RAM2
		asm volatile (".insn r 0x2b, 0, 0b0000100, x23, x3, x4");

		//wait inst 0010000
		asm volatile (".insn r 0x7b, 0, 0b0010000, x0, x0, x0");
		//存储keygen后的随机数ρ，sk，pk

}







void kyber1024_enc(void){
//	//SHA3_Enable,6'b110000
//	//rs1=m rs2=0 dst=额外地址0		//H（m） 256bit
//	asm volatile (".insn r 0x0b, 0, 0b0110000, x0, x0, x0");
	//SHA3_Enable,6'b110011
	//rs1=4 rs2=ρ dst=额外地址2		//H（pk）  256bit
	asm volatile (".insn r 0x0b, 0, 0b0110011, x2, x4, x1");
	//SHA3_Enable,6'b000010
	//rs1=0 rs2=2 dst=3				//G(m|Hpk) K 512bit
	asm volatile (".insn r 0x0b, 0, 0b0000010, x3, x0, x2");


	//SHA3_Enable,6'B010000
	//rs1=r rs2=0 dst=0				//采样r0
	asm volatile (".insn r 0x0b, 0, 0b0010000, x0, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=0 dst=0				//NTT r0 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x16, x0, x0");
	//SHA3_Enable,6'B010001
	//rs1=r rs2=0 dst=1				//采样r1
	asm volatile (".insn r 0x0b, 0, 0b0010001, x1, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=1 dst=1				//NTT r1 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x17, x0, x1");
	//SHA3_Enable,6'B010010
	//rs1=r rs2=0 dst=2				//采样r2
	asm volatile (".insn r 0x0b, 0, 0b0010010, x2, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=2 dst=2				//NTT r2 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x18, x0, x2");
	//SHA3_Enable,6'B010011
	//rs1=r rs2=0 dst=3				//采样r3
	asm volatile (".insn r 0x0b, 0, 0b0010011, x3, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=3 dst=3				//NTT r3 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x19, x0, x3");

///////////////////////////////PWM As0/////////////////////////
	//`SHA3_Enable,6'B100000
	//rs1=ρ rs2=0 dst=0				//采样 AT 00  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100000, x0, x1, x0");

	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=0				//A00 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x16, x0");
	//SHA3_Enable,6'B100100
	//rs1=ρ rs2=0 dst=1				//采样 AT 01  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100100, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=4				//A00 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=0		//A01 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x17, x1");
	//SHA3_Enable,6'B101000
	//rs1=ρ rs2=0 dst=2				//采样 AT 02  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101000, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=5		//A01 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=0		//A02 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x18, x2");
	//SHA3_Enable,6'B101100
	//rs1=ρ rs2=0 dst=3				//采样 AT 03  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101100, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=6		//A02 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=0		//A03 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x19, x3");
	//SHA3_Enable,6'B100001
	//rs1=ρ rs2=0 dst=0				//采样 AT 10  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100001, x0, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=7		//A03 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x0, x1");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=0		//A01s1+A00s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=0 rs2=6 dst=1		//ADD0+A02s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x0, x22");
	//Poly_Enable,`PolyAdd
	//rs1=1 rs2=7 dst=0		//ADD1+A03s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x1, x23");

///////////////////////////////PWM As1/////////////////////////

	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=1				//A10 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x16, x0");
	//SHA3_Enable,6'B100101
	//rs1=ρ rs2=0 dst=1				//采样 AT 11  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100101, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=4				//A10 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x1, x2");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=1		//A11 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x17, x1");
	//SHA3_Enable,6'B101001
	//rs1=ρ rs2=0 dst=2				//采样 AT 12  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101001, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=5		//A11 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x1, x2");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=1		//A12 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x18, x2");
	//SHA3_Enable,6'B101101
	//rs1=ρ rs2=0 dst=3				//采样 AT 13  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101101, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=6		//A12 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x1, x2");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=1		//A13 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x19, x3");
	//SHA3_Enable,6'B100010
	//rs1=ρ rs2=0 dst=0				//采样 AT 20  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100010, x0, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=7		//A13 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x1, x2");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=1		//A11s1+A10s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=1 rs2=6 dst=2		//ADD0+A12s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x1, x22");
	//Poly_Enable,`PolyAdd
	//rs1=2 rs2=7 dst=1		//ADD1+A13s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x2, x23");

///////////////////////////////PWM As2/////////////////////////
	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=2				//A20 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x16, x0");
	//SHA3_Enable,6'B100110
	//rs1=ρ rs2=0 dst=1				//采样 AT 21  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100110, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=4				//A10 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x2, x3");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=2		//A21 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x17, x1");
	//SHA3_Enable,6'B101010
	//rs1=ρ rs2=0 dst=2				//采样 AT 22  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101010, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=5		//A21 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x2, x3");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=2		//A22 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x18, x2");
	//SHA3_Enable,6'B101110
	//rs1=ρ rs2=0 dst=3				//采样 AT 23  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101110, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=6		//A22 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x2, x3");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=2		//A23 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x19, x3");
	//SHA3_Enable,6'B100011
	//rs1=ρ rs2=0 dst=0				//采样 AT 30  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100011, x0, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=7		//A23 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x2, x3");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=2		//A21s1+A20s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=2 rs2=6 dst=3		//ADD0+A22s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x2, x22");
	//Poly_Enable,`PolyAdd
	//rs1=3 rs2=7 dst=2		//ADD1+A23s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x3, x23");

///////////////////////////////PWM As3/////////////////////////
	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=3				//A30 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x16, x0");
	//SHA3_Enable,6'B100111
	//rs1=ρ rs2=0 dst=1				//采样 AT 31  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100111, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=4				//A30 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x3, x4");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=3				//A31 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x17, x1");
	//SHA3_Enable,6'B101011
	//rs1=ρ rs2=0 dst=2				//采样 AT 32  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101011, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=5				//A21 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x3, x4");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=3				//A32 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x18, x2");
	//SHA3_Enable,6'B101111
	//rs1=ρ rs2=0 dst=3				//采样 AT 33  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101111, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=6				//A32 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x3, x4");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=3				//A33 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x19, x3");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=7				//A33 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x3, x4");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=3		//A31s1+A30s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=3 rs2=6 dst=4		//ADD0+A32s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x3, x22");
	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=7 dst=3		//ADD1+A33s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x4, x23");

///////////////////////////////INTT As/////////////////////////
	//SHA3_Enable,6'B010100
	//rs1=r rs2=0 dst=0		//采样e10
	asm volatile (".insn r 0x0b, 0, 0b0010100, x0, x4, x0");
	//Poly_Enable,`INTT
	//rs1=0 rs2=0 dst=4		//intt u[0]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x20, x0, x0");
	//SHA3_Enable,6'B010101
	//rs1=r rs2=0 dst=1		//采样e11
	asm volatile (".insn r 0x0b, 0, 0b0010101, x1, x4, x0");
	//Poly_Enable,`INTT
	//rs1=1 rs2=0 dst=5		//intt u[1]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x21, x1, x0");
	//SHA3_Enable,6'B010110
	//rs1=r rs2=0 dst=2		//采样e12
	asm volatile (".insn r 0x0b, 0, 0b0010110, x2, x4, x0");
	//Poly_Enable,`INTT
	//rs1=2 rs2=0 dst=6		//intt u[2]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x22, x2, x0");
	//SHA3_Enable,6'B010111
	//rs1=r rs2=0 dst=3		//采样e13
	asm volatile (".insn r 0x0b, 0, 0b0010111, x3, x4, x0");
	//Poly_Enable,`INTT
	//rs1=3 rs2=0 dst=7		//intt u[3]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x23, x3, x0");

///////////////////////////////ADD u+e1/////////////////////////
	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=0 dst=0		//e10+u[0]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x20, x0");
	//Poly_Enable,`PolyAdd
	//rs1=5 rs2=1 dst=1		//e11+u[1]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x21, x1");
	//Poly_Enable,`PolyAdd
	//rs1=6 rs2=2 dst=2		//e12+u[2]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x22, x2");
	//Poly_Enable,`PolyAdd
	//rs1=7 rs2=3 dst=3		//e13+u[3]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x23, x3");



	//Poly_Enable,`PWM1
	//rs1=0 rs2=4 dst=4		//r0*t0  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x16, x4");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=4		//r0*t0  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x4, x5");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=5 dst=4		//r1*t1  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x17, x5");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=5		//r1*t1  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x4, x5");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=6 dst=4		//r2*t2  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x18, x6");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=6		//r2*t2  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x4, x5");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=7 dst=4		//r3*t3  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x19, x7");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=7		//r3*t3  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x4, x5");



	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=4		//r0t0+r1t1  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=6 dst=5		//ADD0+r2t2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x5, x4, x22");
	//Poly_Enable,`PolyAdd
	//rs1=5 rs2=7 dst=4		//ADD1+r3t3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x5, x23");

	//SHA3_Enable,6'B011111
	//rs1=r rs2=0 dst=0		//采样e2
	asm volatile (".insn r 0x0b, 0, 0b0011111, x0, x4, x0");
	//Poly_Enable,`INTT
	//rs1=4 rs2=0 dst=4		//intt tr  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x20, x4, x0");


	//Poly_Enable,`Encode_ADD
	//rs1=4 rs2=0 dst=5		//encode_add tr+e2+m  000
	asm volatile (".insn r 0x2b, 0, 0b0000101, x5, x4, x0");


	/////////////////////////////压缩/////////////////////////
	//Poly_Enable,`Compress11
	//rs1=0 rs2=0 dst=0		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x16, x0, x0");
	//Poly_Enable,`Compress11
	//rs1=1 rs2=0 dst=1		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x17, x1, x0");
	//Poly_Enable,`Compress11
	//rs1=2 rs2=0 dst=2		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x18, x2, x0");
	//Poly_Enable,`Compress11
	//rs1=3 rs2=0 dst=3		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x19, x3, x0");
	//Poly_Enable,`Compress5
	//rs1=5 rs2=0 dst=4		//RAM3 to RAM2  001 Compress5
	asm volatile (".insn r 0x2b, 0, 0b0100011, x20, x5, x0");



	//wait inst 0010000
	asm volatile (".insn r 0x7b, 0, 0b0010000, x0, x0, x0");

	//SHA3_Enable,6'b110110
	//rs1=0 rs2=4 dst=0		//Hc 110
	asm volatile (".insn r 0x0b, 0, 0b0110110, x0, x16, x20");

	//SHA3_Enable,6'b011110
	//rs1=3 rs2=0 dst=4	//KDF（K||Hc） 000
	asm volatile (".insn r 0x0b, 0, 0b0011110, x4, x3, x0");
	//wait inst 0010000
	asm volatile (".insn r 0x7b, 0, 0b0010000, x0, x0, x0");
}

void kyber1024_dec(void){
/////////////////////////////解压/////////////////////////
	//Poly_Enable,`DeCompress11
	//rs1=0 rs2=0 dst=0		//RAM2 to RAM3  100 DeCompress11
	asm volatile (".insn r 0x2b, 0, 0b0101010, x0, x16, x0");
	//Poly_Enable,`DeCompress11
	//rs1=1 rs2=0 dst=1		//RAM2 to RAM3  100 DeCompress11
	asm volatile (".insn r 0x2b, 0, 0b0101010, x1, x17, x0");
	//Poly_Enable,`DeCompress11
	//rs1=2 rs2=0 dst=2		//RAM2 to RAM3  100 DeCompress11
	asm volatile (".insn r 0x2b, 0, 0b0101010, x2, x18, x0");
	//Poly_Enable,`DeCompress11
	//rs1=3 rs2=0 dst=3		//RAM2 to RAM3  100 DeCompress11
	asm volatile (".insn r 0x2b, 0, 0b0101010, x3, x19, x0");
	//Poly_Enable,`DeCompress5
	//rs1=4 rs2=0 dst=4		//RAM2 to RAM3  100 DeCompress5
	asm volatile (".insn r 0x2b, 0, 0b0101011, x4, x20, x0");


	//Poly_Enable,`NTT
	//rs1=0 rs2=0 dst=0    //NTT u0 011 RAM3 to RAM2
	asm volatile (".insn r 0x2b, 0, 0b0000000, x16, x0, x16");
	//Poly_Enable,`NTT
	//rs1=1 rs2=0 dst=1    //NTT u1 011 RAM3 to RAM2
	asm volatile (".insn r 0x2b, 0, 0b0000000, x17, x1, x16");
	//Poly_Enable,`NTT
	//rs1=2 rs2=0 dst=2    //NTT u2 011 RAM3 to RAM2
	asm volatile (".insn r 0x2b, 0, 0b0000000, x18, x2, x16");
	//Poly_Enable,`NTT
	//rs1=3 rs2=0 dst=3    //NTT u3 011 RAM3 to RAM2
	asm volatile (".insn r 0x2b, 0, 0b0000000, x19, x3, x16");

	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=0		//u0*s0  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x16, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=4		//u0*s0  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=0		//u1*s1  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x17, x1");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=5		//u1*s1  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=0		//u2*s2  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x18, x2");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=6		//u2*s2  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=0		//u3*s3  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x19, x3");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=7		//u3*s3  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x0, x1");

//	//SHA3_Enable,6'b110011
//		//rs1=4 rs2=ρ dst=5	//H（pk） 000
//		asm volatile (".insn r 0x0b, 0, 0b0110011, x11, x4, x1");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=0		//u0s0+u1s1  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=0 rs2=6 dst=1		//ADD0+u2s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x0, x22");
	//Poly_Enable,`PolyAdd
	//rs1=1 rs2=7 dst=0		//ADD1+u3s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x1, x23");

	//Poly_Enable,`INTT
	//rs1=0 rs2=0 dst=4		//intt su  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x20, x0, x0");

	//Poly_Enable,`Decode_SUB
	//rs1=4 rs2=4 dst=8	//decode su + v = m  000
	asm volatile (".insn r 0x2b, 0, 0b0000110, x8, x4, x4");

	/////////////////////////////存解密后的明文/////////////////////////
	//wait inst 0010000
	asm volatile (".insn r 0x7b, 0, 0b0010000, x0, x0, x0");
}




void kyber1024_enc_verify(void){
	//SHA3_Enable,6'b000010
	//rs1=0 rs2=2 dst=3				//G(m|Hpk) K 512bit
	asm volatile (".insn r 0x0b, 0, 0b0000010, x3, x0, x2");


	//SHA3_Enable,6'B010000
	//rs1=r rs2=0 dst=0				//采样r0
	asm volatile (".insn r 0x0b, 0, 0b0010000, x0, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=0 dst=0				//NTT r0 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x16, x0, x0");
	//SHA3_Enable,6'B010001
	//rs1=r rs2=0 dst=1				//采样r1
	asm volatile (".insn r 0x0b, 0, 0b0010001, x1, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=1 dst=1				//NTT r1 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x17, x0, x1");
	//SHA3_Enable,6'B010010
	//rs1=r rs2=0 dst=2				//采样r2
	asm volatile (".insn r 0x0b, 0, 0b0010010, x2, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=2 dst=2				//NTT r2 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x18, x0, x2");
	//SHA3_Enable,6'B010011
	//rs1=r rs2=0 dst=3				//采样r3
	asm volatile (".insn r 0x0b, 0, 0b0010011, x3, x4, x0");
	//Poly_Enable,`NTT
	//rs1=0 rs2=3 dst=3				//NTT r3 001 RAM3+RAM1第一轮 to RAM2
	asm volatile (".insn r 0x2b, 1, 0, x19, x0, x3");

///////////////////////////////PWM As0/////////////////////////
	//`SHA3_Enable,6'B100000
	//rs1=ρ rs2=0 dst=0				//采样 AT 00  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100000, x0, x1, x0");

	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=0				//A00 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x16, x0");
	//SHA3_Enable,6'B100100
	//rs1=ρ rs2=0 dst=1				//采样 AT 01  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100100, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=4				//A00 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=0		//A01 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x17, x1");
	//SHA3_Enable,6'B101000
	//rs1=ρ rs2=0 dst=2				//采样 AT 02  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101000, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=5		//A01 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=0		//A02 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x18, x2");
	//SHA3_Enable,6'B101100
	//rs1=ρ rs2=0 dst=3				//采样 AT 03  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101100, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=6		//A02 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x0, x1");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=0		//A03 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x0, x19, x3");
	//SHA3_Enable,6'B100001
	//rs1=ρ rs2=0 dst=0				//采样 AT 10  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100001, x0, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=0 rs2=1 dst=7		//A03 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x0, x1");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=0		//A01s1+A00s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=0 rs2=6 dst=1		//ADD0+A02s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x0, x22");
	//Poly_Enable,`PolyAdd
	//rs1=1 rs2=7 dst=0		//ADD1+A03s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x1, x23");

///////////////////////////////PWM As1/////////////////////////

	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=1				//A10 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x16, x0");
	//SHA3_Enable,6'B100101
	//rs1=ρ rs2=0 dst=1				//采样 AT 11  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100101, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=4				//A10 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x1, x2");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=1		//A11 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x17, x1");
	//SHA3_Enable,6'B101001
	//rs1=ρ rs2=0 dst=2				//采样 AT 12  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101001, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=5		//A11 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x1, x2");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=1		//A12 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x18, x2");
	//SHA3_Enable,6'B101101
	//rs1=ρ rs2=0 dst=3				//采样 AT 13  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101101, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=6		//A12 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x1, x2");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=1		//A13 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x1, x19, x3");
	//SHA3_Enable,6'B100010
	//rs1=ρ rs2=0 dst=0				//采样 AT 20  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100010, x0, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=1 rs2=2 dst=7		//A13 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x1, x2");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=1		//A11s1+A10s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=1 rs2=6 dst=2		//ADD0+A12s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x1, x22");
	//Poly_Enable,`PolyAdd
	//rs1=2 rs2=7 dst=1		//ADD1+A13s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x2, x23");

///////////////////////////////PWM As2/////////////////////////
	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=2				//A20 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x16, x0");
	//SHA3_Enable,6'B100110
	//rs1=ρ rs2=0 dst=1				//采样 AT 21  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100110, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=4				//A10 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x2, x3");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=2		//A21 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x17, x1");
	//SHA3_Enable,6'B101010
	//rs1=ρ rs2=0 dst=2				//采样 AT 22  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101010, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=5		//A21 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x2, x3");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=2		//A22 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x18, x2");
	//SHA3_Enable,6'B101110
	//rs1=ρ rs2=0 dst=3				//采样 AT 23  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101110, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=6		//A22 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x2, x3");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=2		//A23 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x2, x19, x3");
	//SHA3_Enable,6'B100011
	//rs1=ρ rs2=0 dst=0				//采样 AT 30  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100011, x0, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=2 rs2=3 dst=7		//A23 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x2, x3");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=2		//A21s1+A20s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=2 rs2=6 dst=3		//ADD0+A22s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x2, x22");
	//Poly_Enable,`PolyAdd
	//rs1=3 rs2=7 dst=2		//ADD1+A23s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x3, x23");

///////////////////////////////PWM As3/////////////////////////
	//Poly_Enable,`PWM1
	//rs1=0 rs2=0 dst=3				//A30 r0 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x16, x0");
	//SHA3_Enable,6'B100111
	//rs1=ρ rs2=0 dst=1				//采样 AT 31  ρ
	asm volatile (".insn r 0x0b, 0, 0b0100111, x1, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=4				//A30 r0 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x3, x4");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=1 dst=3				//A31 r1 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x17, x1");
	//SHA3_Enable,6'B101011
	//rs1=ρ rs2=0 dst=2				//采样 AT 32  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101011, x2, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=5				//A21 r1 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x3, x4");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=2 dst=3				//A32 r2 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x18, x2");
	//SHA3_Enable,6'B101111
	//rs1=ρ rs2=0 dst=3				//采样 AT 33  ρ
	asm volatile (".insn r 0x0b, 0, 0b0101111, x3, x1, x0");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=6				//A32 r2 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x3, x4");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=3 dst=3				//A33 r3 PWM1 100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x3, x19, x3");
	//Poly_Enable,`PWM2
	//rs1=3 rs2=4 dst=7				//A33 r3 PWM2 001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x3, x4");

	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=3		//A31s1+A30s0  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=3 rs2=6 dst=4		//ADD0+A32s2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x3, x22");
	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=7 dst=3		//ADD1+A33s3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x4, x23");

///////////////////////////////INTT As/////////////////////////
	//SHA3_Enable,6'B010100
	//rs1=r rs2=0 dst=0		//采样e10
	asm volatile (".insn r 0x0b, 0, 0b0010100, x0, x4, x0");
	//Poly_Enable,`INTT
	//rs1=0 rs2=0 dst=4		//intt u[0]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x20, x0, x0");
	//SHA3_Enable,6'B010101
	//rs1=r rs2=0 dst=1		//采样e11
	asm volatile (".insn r 0x0b, 0, 0b0010101, x1, x4, x0");
	//Poly_Enable,`INTT
	//rs1=1 rs2=0 dst=5		//intt u[1]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x21, x1, x0");
	//SHA3_Enable,6'B010110
	//rs1=r rs2=0 dst=2		//采样e12
	asm volatile (".insn r 0x0b, 0, 0b0010110, x2, x4, x0");
	//Poly_Enable,`INTT
	//rs1=2 rs2=0 dst=6		//intt u[2]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x22, x2, x0");
	//SHA3_Enable,6'B010111
	//rs1=r rs2=0 dst=3		//采样e13
	asm volatile (".insn r 0x0b, 0, 0b0010111, x3, x4, x0");
	//Poly_Enable,`INTT
	//rs1=3 rs2=0 dst=7		//intt u[3]  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x23, x3, x0");

///////////////////////////////ADD u+e1/////////////////////////
	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=0 dst=0		//e10+u[0]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x0, x20, x0");
	//Poly_Enable,`PolyAdd
	//rs1=5 rs2=1 dst=1		//e11+u[1]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x1, x21, x1");
	//Poly_Enable,`PolyAdd
	//rs1=6 rs2=2 dst=2		//e12+u[2]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x2, x22, x2");
	//Poly_Enable,`PolyAdd
	//rs1=7 rs2=3 dst=3		//e13+u[3]  100  RAM2+RAM1=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x3, x23, x3");



	//Poly_Enable,`PWM1
	//rs1=0 rs2=4 dst=4		//r0*t0  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x16, x4");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=4		//r0*t0  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x20, x4, x5");

	//Poly_Enable,`PWM1
	//rs1=1 rs2=5 dst=4		//r1*t1  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x17, x5");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=5		//r1*t1  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x21, x4, x5");

	//Poly_Enable,`PWM1
	//rs1=2 rs2=6 dst=4		//r2*t2  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x18, x6");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=6		//r2*t2  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x22, x4, x5");

	//Poly_Enable,`PWM1
	//rs1=3 rs2=7 dst=4		//r3*t3  PWM1  100
	asm volatile (".insn r 0x2b, 0, 0b0000010, x4, x19, x7");
	//Poly_Enable,`PWM2
	//rs1=4 rs2=5 dst=7		//r3*t3  PWM2   001
	asm volatile (".insn r 0x2b, 0, 0b0000011, x23, x4, x5");



	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=5 dst=4		//r0t0+r1t1  110  RAM2+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x20, x21");
	//Poly_Enable,`PolyAdd
	//rs1=4 rs2=6 dst=5		//ADD0+r2t2  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x5, x4, x22");
	//Poly_Enable,`PolyAdd
	//rs1=5 rs2=7 dst=4		//ADD1+r3t3  010  RAM3+RAM2=RAM3
	asm volatile (".insn r 0x2b, 0, 0b0000100, x4, x5, x23");

	//SHA3_Enable,6'B011111
	//rs1=r rs2=0 dst=0		//采样e2
	asm volatile (".insn r 0x0b, 0, 0b0011111, x0, x4, x0");
	//Poly_Enable,`INTT
	//rs1=4 rs2=0 dst=4		//intt tr  001
	asm volatile (".insn r 0x2b, 0, 0b0000001, x20, x4, x0");


	//Poly_Enable,`Encode_ADD
	//rs1=4 rs2=0 dst=5		//encode_add tr+e2+m  000
	asm volatile (".insn r 0x2b, 0, 0b0000101, x5, x4, x0");


	/////////////////////////////压缩/////////////////////////
	//Poly_Enable,`Compress11
	//rs1=0 rs2=0 dst=0		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x16, x0, x0");
	//Poly_Enable,`Compress11
	//rs1=1 rs2=0 dst=1		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x17, x1, x0");
	//Poly_Enable,`Compress11
	//rs1=2 rs2=0 dst=2		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x18, x2, x0");
	//Poly_Enable,`Compress11
	//rs1=3 rs2=0 dst=3		//RAM3 to RAM2  001 Compress11
	asm volatile (".insn r 0x2b, 0, 0b0100010, x19, x3, x0");
	//Poly_Enable,`Compress5
	//rs1=5 rs2=0 dst=4		//RAM3 to RAM2  001 Compress5
	asm volatile (".insn r 0x2b, 0, 0b0100011, x20, x5, x0");



	//wait inst 0010000
	asm volatile (".insn r 0x7b, 0, 0b0010000, x0, x0, x0");

	//SHA3_Enable,6'b110110
	//rs1=0 rs2=4 dst=0		//Hc 110
	asm volatile (".insn r 0x0b, 0, 0b0110110, x0, x16, x20");

	//SHA3_Enable,6'b011110
	//rs1=3 rs2=0 dst=4	//KDF（K||Hc） 000
	asm volatile (".insn r 0x0b, 0, 0b0011110, x4, x3, x0");
	//wait inst 0010000
	asm volatile (".insn r 0x7b, 0, 0b0010000, x0, x0, x0");
}
